import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import '../../public/repeat_fun.dart';
import '../../public/itemList.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart';

class Education extends StatefulWidget {
  Education({Key key}) : super(key: key);

  @override
  _EducationState createState() => _EducationState();
}

class _EducationState extends State<Education>
    with SingleTickerProviderStateMixin {
  TabController _tabController;
  List<Widget> tabs = [
    Text("专题1"),
    Text("专题2"),
    Text("专题3"),
  ];
  @override
  void initState() {
    super.initState();
    print('this${this}');
    _tabController = TabController(length: 3, vsync: this);
  }

  void dispose() {
    _tabController.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return PreferredSize(
      child: Scaffold(
          appBar: AppBar(
            elevation: 0,
            leading: moveBack(context),
            centerTitle: true,
            title: Text("教育专题"),
            bottom: TabBar(
              indicatorWeight: 3.0,
              labelPadding: EdgeInsets.fromLTRB(0, 10.h, 0, 25.h),
              indicatorSize: TabBarIndicatorSize.label,
              labelStyle: TextStyle(color: Colors.yellow, fontSize: 35.sp),
              tabs: this.tabs,
              controller: _tabController,
            ),
          ),
          body: TabBarView(
            controller: _tabController,
            children: <Widget>[
              Special(),
              Special(),
              Special(),
            ],
          )),
      preferredSize: Size.fromHeight(100.h),
    );
  }
}

class Special extends StatefulWidget {
  Special({Key key}) : super(key: key);

  @override
  _SpecialState createState() => _SpecialState();
}

class _SpecialState extends State<Special> {
  EasyRefreshController _easController;
  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    _easController = EasyRefreshController();
  }

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: EdgeInsets.fromLTRB(15.w, 25.h, 0, 0),
      child: EasyRefresh(
        child: ListView.builder(
          itemBuilder: (context, index) {
            return ItemOption();
          },
          itemCount: 15,
        ),
        onRefresh: () async {},
        onLoad: () async {
          // _controller.finishLoad(success: true, noMore: false);
        },
      ),
    );
  }
}
